//
//  XDTools.h
//  XDBaseFrameWork
//
//  Created by XD-XY on 9/18/14.
//  Copyright (c) 2014 XD-XY. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "AppDelegate.h"
#import "MBProgressHUD.h"
#import "JSONKit.h"
#import "FMDB.h"
#import "NSString+Base64Str.h"

#import "ASIHTTPRequest.h"
#import "ASIFormDataRequest.h"
#import "ASINetworkQueue.h"
#import "Reachability.h"
#import "UIImageView+WebCache.h"

#import "orderDetailViewController.h"

#import "ChooseImageViewController.h"

#import "OrderConfirmViewController.h"

#import "APPointmentHospitalViewController.h"

@interface XDTools : NSObject

DEFINE_SINGLETON_FOR_HEADER(XDTools)

@property(nonatomic,assign)CGFloat latitude;
@property(nonatomic,assign)CGFloat longitude;

@property(nonatomic,strong)NSString * iphoneNumber; //手机号
@property(nonatomic,strong)NSString * time;         //预约时间
@property(nonatomic,strong)NSString * adderss;      //地址

@property(nonatomic,strong)NSString * taocanImgUrl; //套餐图片
@property(nonatomic,strong)NSString * taocanName;   //套餐名称
@property(nonatomic,strong)NSString * taocanDesc;   //套餐描述
@property(nonatomic,strong)NSString * taocanPrcie;  //套餐价格
@property(nonatomic,strong)NSString * taocanMarketPrice;  //市场价格

@property(nonatomic,strong)NSString * emplImgUrl;   //摄影师头像
@property(nonatomic,strong)NSString * emplName;
@property(nonatomic,strong)NSString * emplLevel;    //摄影师等级
@property(nonatomic,strong)NSString * emplZhuanYe;  //摄影师专业
@property(nonatomic,strong)NSString * emplGouTong;  //摄影师沟通
@property(nonatomic,strong)NSString * emplShoushi;  //摄影师守时

//用来传值
@property(nonatomic,strong)NSString * SceneID;      //场景ID
@property(nonatomic,strong)NSString * CustomerID;   //顾客ID
@property(nonatomic,strong)NSString * EmplID;       //摄影师ID
@property(nonatomic,strong)NSString * SeriesID;     //套餐ID
@property(nonatomic,strong)NSString * CityID;       //城市ID
@property(nonatomic,strong)NSString * ShootDate;    //订单时间
@property(nonatomic,strong)NSString * ShootAddr;    //订单地址
@property(nonatomic,strong)NSString * ModeID;       //拍摄方式ID
@property(nonatomic,strong)NSString * content;      //订单留言
@property(nonatomic,strong)NSString * PSID;         //影棚ID
@property(nonatomic,assign) BOOL haveYouHuiQuan;  //是否有优惠券

//用来存放两个支付界面的指针

@property (nonatomic,assign)orderDetailViewController *orderDetailVC;           //订单详情
@property (nonatomic,assign)ChooseImageViewController *chooseImageVC;           //选片页面
@property (nonatomic,assign)OrderConfirmViewController *OrderConfirmVC;         //订单确认页
@property (nonatomic,assign)APPointmentHospitalViewController * hospitalVC;      //出生照支付页
//获取Appdelegate 指针
+ (AppDelegate *)appDelegate;

//jsonkit 解析json格式
+ (NSDictionary *)JSonFromString:(NSString*)result;

//显示指示器
+ (void)showProgress:(UIView *) view;

//显示指示器和文字
+ (void)showProgress:(UIView *) view showText:(NSString*)text;

//显示指示器文字
+ (void) showTips:(NSString *)text toView:(UIView *)view;

//显示成功标识指示器和文字以及自定义图片
+ (void)showSuccessTips:(NSString *)text image:(UIImage *)image toView:(UIView *)view;

//显示失败标识指示器和文字
+ (void)showErrorTips:(NSString *)text toView:(UIView *)view;

//隐藏指示器
+ (void)hideProgress:(UIView *)view;

//将字典、数组转换成json串
+(NSString *)stringFromObject:(id)obj;

//将json串反解析
+(id)objectFromString:(NSString *)str;

//获取uuid
-(NSString *)gen_uuid;

//判断当前时间和过去时间的时间差
- (NSString *)intervalSinceNow:(NSString *) theDate;

//将工程目录文件移动到沙河目录Documnet下
+(void)moveFileToDocument:(NSString *)name andType:(NSString *)type;

//Label自适应大小
+(CGRect )autoSizeOfWidget:(UILabel *)widget andSize:(CGSize)size andtextFont:(CGFloat )sizefont;

//计算文字宽和长
+(CGRect )autoSizeOftext:(NSString *)text andSize:(CGSize)size andtextFont:(CGFloat)sizefont;

//图片无损拉伸
+(UIImage *)stretchableImag:(UIImage *)image;

//获取数据库指针
+(FMDatabase*)getDb;

//GET 请求 获取数据
+ (ASIHTTPRequest*)getRequestWithDict:(NSDictionary *)dict API:(NSString *)api;

//POST 请求 获取数据
+ (ASIFormDataRequest*)postRequestWithDict:(NSDictionary *)dict API:(NSString *)api;

//POST 请求 上传文件
+ (ASIFormDataRequest*)postRequestWithDict:(NSDictionary *)dict API:(NSString *)api  fileName:(NSString *)filename  fileData:(NSData *)data;

//判断有无网络
+ (BOOL)NetworkReachable;

//计算缓存
-(void)CalculateTheCache:(UILabel *)label;

//清理缓存
-(void)clearTheCache:(UILabel *)label;

//创建cell的分割线
-(UIView *)createSeparatorLineWithRect:(CGRect)rect;

//打电话
+(void)MakeAPhoneCall;

//编辑字符串颜色，大小
+(NSMutableAttributedString *)getAcolorfulStringWithTextArray:(NSArray *)array Color:(UIColor *)color Font:(UIFont *)font AllText:(NSString *)allText;


//验证手机号
+(BOOL)chickIphoneNumberRight:(NSString *)str;

+ (ASIFormDataRequest*)postRequestWithDict:(NSDictionary *)dict API:(NSString *)api data:(NSData *)data;

//从数据库获取数据
+ (NSMutableArray *)getArrayWithKey:(NSString *)key table:(NSString *)table;

//转换接片量为等级
+ (NSInteger)changeOrderCountToLevel:(NSInteger)orderCount;


@end
